package com.bmft.ftcloud.service;

import com.bmft.ftcloud.config.BeanConfig;
import com.bmft.ftcloud.util.redis.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @author Jarvan
 * @version 1.0
 * @create 2020/12/2 19:13
 */
@Service
public class RedisService {
    @Autowired
    RedisUtil redisUtil;
    @Autowired
    BeanConfig beanConfig;

    /**
     * 储存到redis默认5分钟.异步储存到redis.
     * @param key
     * @param value
     * @return
     */
    @Async
    public void set(String key,String value){
        redisUtil.set(key,value,beanConfig.getRedisSaveTime());
    }

    /**
     * get
     * @param key
     * @return
     */
    public Object get(String key){
        return redisUtil.get(key);
    }
    @Async
    public void delete(String key){
        redisUtil.del();
    }
}
